# -*- coding=utf-8 -*-
import sys
import cx_Oracle

from faker import Factory
f = Factory.create()


print(sys.getdefaultencoding())




conn  = cx_Oracle.connect("test","oracle","omaster")
cursor = conn.cursor()

cursor.execute("""
    select max(id) from person
""")

max_id = cursor.fetchone()

begin = 0
if(max_id[0] != None):
    begin = max_id[0] + 1
print(begin)

insertsql = "insert into person values(:1,:2,:3,:4,:5,:6,:7,:8,:9)"

cursor.prepare(insertsql)


itemlist = list()
for  i in range(1000):
    itemid =  begin + i
    person_item = (itemid,f.name(),f.country(),f.city(),f.city(),f.company(),f.phone_number(),f.email(),f.job())
    itemlist.append(person_item)
    
    if  i % 100 == 0 : 
        cursor.executemany(None,itemlist)
        conn.commit()
        itemlist.clear()

cursor.executemany(None,itemlist)
conn.commit()
itemlist.clear()

conn.close()